<%@ Register TagPrefix="uc1" TagName="Footer" Src="../Controls/Footer.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="../Controls/Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="HelpCtrl" Src="../Controls/HelpCtrl.ascx" %>
<%@ Page validateRequest="false" Language="vb" AutoEventWireup="false" Codebehind="ProductionStatusUpdate.aspx.vb" Inherits="MIMS_WRS.Web.ProductionStatusUpdate" smartNavigation="False"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>Update Production Status</title>
		<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<script language="javascript" src="../Js/popcalendar.js"></script>
		<script language="javascript" src="../Js/common.js"></script>
		<LINK href="../style.css" type="text/css" rel="stylesheet">
		<script language="JavaScript" src="../js/function.js" type="text/JavaScript"></script>
		<script language="javascript">
		<!--
		
		var productCount = <%= PageBOCol.Count %>;		
		
		function body_onload() {
			if (window.document.getElementById('btnSave'))
				window.document.getElementById('btnSave').onclick = btnSubmit_onclick;
			if (window.document.getElementById('btnSaveAndCont'))
				window.document.getElementById('btnSaveAndCont').onclick = btnSubmit_onclick;
		}
		
		function btnSubmit_onclick() {
		
			ConfigValidatorStatus();
							
			if (typeof(Page_ClientValidate) == 'function') 
				return Page_ClientValidate();
							
			return false;
		}
		
		function ConfigValidatorStatus()
		{
			var i;
			for(i=1; i<=productCount; ++i)
			{
				var needValidation;
				needValidation = ProductHasData(i);
				UpdateValidatorStatus(i, needValidation);
			}
		}
		
		function ProductHasData(i)
		{
			var qtCompleted = "repProduct__ctl" + i + "_txtQuantityCompleted";
			var qtBelow50 = "repProduct__ctl" + i + "_txtQuantityBelow50"
			var qtAbove50 = "repProduct__ctl" + i + "_txtQuantityAbove50";
			var completedDate = "repProduct__ctl" + i + "_txt100CompletedDate";
			
			if(ControlHasData(qtCompleted))
				return true;
			if(ControlHasData(qtBelow50))
				return true;
			if(ControlHasData(qtAbove50))
				return true;
			if(ControlHasData(completedDate))
				return true;
			
			return false;		
		}
		
		function ControlHasData(ctrlName)
		{
			if (window.document.getElementById(ctrlName))
			{
				var value = window.document.getElementById(ctrlName).value;
				value = trimLeft(value);
				value = trimRight(value);
				if(value.length > 0)
				{
					return true;
				}
			}
			
			return false;			
		}

		function UpdateValidatorStatus(i, needValidation)
		{
			var validator1 = "repProduct__ctl" + i + "_RequiredFieldValidator2";			
			var validator2 = "repProduct__ctl" + i + "_comvQuantityCompleted";			
			var validator3 = "repProduct__ctl" + i + "_Requiredfieldvalidator5";			
			var validator4 = "repProduct__ctl" + i + "_comvBelow50";			
			var validator5 = "repProduct__ctl" + i + "_RequiredFieldValidator3";			
			var validator6 = "repProduct__ctl" + i + "_comvAbove50";			
			var validator7 = "repProduct__ctl" + i + "_reqv100Completed";			
			
			UpdateSingleValidatorStatus(validator1, needValidation);						
			UpdateSingleValidatorStatus(validator2, needValidation);						
			UpdateSingleValidatorStatus(validator3, needValidation);						
			UpdateSingleValidatorStatus(validator4, needValidation);						
			UpdateSingleValidatorStatus(validator5, needValidation);						
			UpdateSingleValidatorStatus(validator6, needValidation);						
			UpdateSingleValidatorStatus(validator7, needValidation);						
		}
		
		function UpdateSingleValidatorStatus(ctrlName, needValidation)
		{
			if (window.document.getElementById(ctrlName))
			{
				var ctrl = window.document.getElementById(ctrlName);
				ctrl.enabled = needValidation;	
			}
		}
		
		function OpenPOTrans(idx, oiID) {
			var reval;			
			var title = "Quantity Transferred by PO";
			var url=escape('TransferDialog.aspx?idx='+ idx + '&oiID=' + oiID);
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: 300px; dialogWidth: 600px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			if (reval != null)
				return true;
			else
				return false;
		}
		
		function LoadPreviousWeekValues(idx, hasPreviousValue)
		{
			if(!hasPreviousValue)
				return;
		
			idx = (parseInt(idx) + 1); 
			var hidQtyCompletedLastID = "repProduct__ctl" + idx + "_hidQtyCompletedLast";
			var hidQtyB50LastID = "repProduct__ctl" + idx + "_hidQtyB50Last"
			var hidQtyA50LastID = "repProduct__ctl" + idx + "_hidQtyA50Last"
			var hidEstCompletedLastID = "repProduct__ctl" + idx + "_hidEstCompletedLast"
			
			var txtQuantityCompletedID = "repProduct__ctl" + idx + "_txtQuantityCompleted";
			var txtQuantityBelow50ID = "repProduct__ctl" + idx + "_txtQuantityBelow50"
			var txtQuantityAbove50ID = "repProduct__ctl" + idx + "_txtQuantityAbove50"
			var txt100CompletedDateID = "repProduct__ctl" + idx + "_txt100CompletedDate"
			
			LoadPreviousValue(hidQtyCompletedLastID, txtQuantityCompletedID)
			LoadPreviousValue(hidQtyB50LastID, txtQuantityBelow50ID)
			LoadPreviousValue(hidQtyA50LastID, txtQuantityAbove50ID)
			LoadPreviousValue(hidEstCompletedLastID, txt100CompletedDateID)
		}	
		
		function LoadPreviousValue(hiddenID, textBoxID)
		{
			var previousValue = window.document.getElementById(hiddenID).value
			var txtInput = window.document.getElementById(textBoxID)
			
			if(previousValue == "N/A")
				txtInput.value = ""	
			else
				txtInput.value = previousValue
		}
		
		//-->
		</script>
	</HEAD>
	<body leftMargin="0" topMargin="0" onload="body_onload();MM_preloadImages('../images/b_weeklyreporto.gif','../images/b_historyreporto.gif','../images/b_usero.gif')">
		<form id="Form1" method="post" runat="server">
			<table id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0">
				<uc1:header id="Header1" runat="server"></uc1:header>
				<!-- Submenu: start -->
				<tr>
					<td class="bgsubmenu" align="center" height="30">
						<div class="nlink">
							<table id="Table2" cellSpacing="0" cellPadding="0" width="96%" border="0">
								<tr>
									<td class="txtcolor2"><span class="txtsmall"><strong>You are here:</strong></span> <A href="../Internal/OrderList.aspx">
											Order list</A> / Update Production status
									</td>
									<td class="txtcolor2" align="right">
										<p><A href="../Internal/OrderInput.aspx"><strong>Create New Order</strong></A></p>
									</td>
									<td class="txtcolor2" noWrap align="right" width="70"><span class="plink"><A href="javascript:history.back()"><IMG height="16" hspace="2" src="../images/b_back.gif" width="57" vspace="0" border="0"></A></span></td>
								</tr>
							</table>
						</div>
					</td>
				</tr>
				<tr>
					<td class="bglinetop1" height="1"><IMG height="1" src="../images/1pxl.gif" width="1"></td>
				</tr>
				<!-- Submenu: end -->
				<tr>
					<td class="bgwhite" align="center">
						<table id="Table3" cellSpacing="0" cellPadding="0" width="90%" border="0">
							<tr>
								<td vAlign="bottom" align="center" height="10"><IMG height="1" src="../images/1pxl.gif" width="1"></td>
							</tr>
							<tr>
								<td align="center" height="35">
									<table id="Table4" cellSpacing="0" cellPadding="0" width="100%" border="0">
										<tr>
											<td vAlign="bottom" width="56%" height="25"><span class="title"><strong><strong>UPDATE 
															PRODUCTION STATUS</strong></strong></span></td>
											<td vAlign="bottom" align="right" width="44%"><div class="plink"><span class="txtcolor2"><strong><span class="txtsmall"><A href="#"><uc1:helpctrl id="HelpCtrl1" runat="server"></uc1:helpctrl></A></span></strong></span></div>
											</td>
										</tr>
									</table>
									<table id="msgTable" style="DISPLAY: none" height="25" cellSpacing="0" cellPadding="0"
										width="100%" border="0">
										<tr>
											<td class="txthighlight" align="center">Your Production Status has been updated 
												successfully!</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td vAlign="top" align="center">
									<table class="border1" id="Table5" cellSpacing="2" cellPadding="2" width="100%" border="0">
										<tr>
											<td align="center" bgColor="#f9f9f9">
												<TABLE id="Table6" cellSpacing="0" cellPadding="3" width="100%" border="0">
													<TBODY>
														<TR class="bgmenu">
															<TD align="right" width="32%" height="20">&nbsp;</TD>
															<TD align="center" width="1%">&nbsp;</TD>
															<TD width="22%">&nbsp;</TD>
															<TD align="right" width="15%">&nbsp;</TD>
															<TD align="center" width="1%">&nbsp;</TD>
															<TD width="29%">&nbsp;</TD>
														</TR>
														<TR class="txtnormal">
															<TD align="right"></TD>
															<TD align="center"></TD>
															<TD class="txtcolor2" colSpan="4"><asp:label id="lblStatus" runat="server" Font-Bold="True"></asp:label></TD>
														</TR>
														<TR class="txtnormal">
															<TD align="right" height="20">Order Date:</TD>
															<TD align="center">&nbsp;</TD>
															<TD class="txtcolor2"><strong><asp:label id="lblOrderDate" runat="server"></asp:label></strong></TD>
															<TD align="right"></TD>
															<TD align="center">&nbsp;</TD>
															<TD class="txtcolor2"></TD>
														</TR>
														<TR class="txtnormal">
															<TD align="right">Customer:</TD>
															<TD align="center">&nbsp;</TD>
															<TD class="txtcolor2"><strong><asp:label id="lblCustomerName" runat="server"></asp:label></strong></TD>
															<TD noWrap align="right"><asp:label id="lblOrderNoText" Runat="server"></asp:label>:</TD>
															<TD align="center">&nbsp;</TD>
															<TD class="txtcolor2"><strong><asp:label id="lblOrderNo" runat="server"></asp:label></strong></TD>
														</TR>
														<TR class="txtnormal">
															<TD align="right">Week:</TD>
															<TD align="center">&nbsp;</TD>
															<TD class="txtcolor2"><strong><asp:label id="lblWeek" runat="server"></asp:label></strong></TD>
															<TD align="right">Year:</TD>
															<TD align="center">&nbsp;</TD>
															<TD class="txtcolor2"><strong><asp:label id="lblYear" runat="server"></asp:label></strong></TD>
														</TR>
														<TR class="txtnormal">
															<TD align="right">&nbsp;</TD>
															<TD align="center">&nbsp;</TD>
															<TD noWrap>&nbsp;</TD>
															<TD align="right">&nbsp;</TD>
															<TD align="center">&nbsp;</TD>
															<TD>&nbsp;</TD>
														</TR>
														<TR class="txtnormal">
															<TD colSpan="6"><asp:repeater id="repProduct" runat="server">
																	<HeaderTemplate>
																		<table width="100%" border="0" cellpadding="3" cellspacing="1" class="border">
																			<tr class="bggrey">
																				<td height="25" rowspan="3" align="center"><strong>Product Information</strong><br>
																					(Code-Description-Color)</td>
																				<td height="25" rowspan="3" align="center"><strong>Revise Total Qty Ordered</strong></td>
																				<td colspan="2" rowspan="2" align="center"><strong> Quantity Completed</strong></td>
																				<td colspan="4" align="center"><strong>Quantity in Progress</strong></td>
																				<td colspan="2" rowspan="2" align="center"><strong>Estimated<br>
																						100% Completion Date</strong></td>
																				<td rowspan="3" align="center"><strong>Load<br>
																						previous<br>
																						value</strong></td>
																			</tr>
																			<tr class="txtnormal">
																				<td colspan="2" align="center" class="bggrey"><strong>Below 50%</strong></td>
																				<td colspan="2" align="center" class="bggrey"><strong>Above 50%</strong></td>
																			</tr>
																			<tr class="txtnormal">
																				<td align="center" class="bggrey">Last Value</td>
																				<td align="center" class="bggrey">Adjusting Quantity</td>
																				<td align="center" class="bggrey">Last Value</td>
																				<td align="center" class="bggrey">Adjusting Quantity</td>
																				<td align="center" class="bggrey">Last Value</td>
																				<td align="center" class="bggrey">Adjusting Quantity</td>
																				<td align="center" class="bggrey">Last Update</td>
																				<td align="center" class="bggrey">Adjusting Date
																				</td>
																			</tr>
																	</HeaderTemplate>
																	<ItemTemplate>
																		<tr class="bgwhite">
																			<td><input type=hidden runat=server id=hidBOIndex value='<%# DataBinder.Eval(Container, "DataItem.BOIndex") %>'>
																				<%# DataBinder.Eval(Container, "DataItem.ProductInfo") %>
																			</td>
																			<td width="9%" align="center"><span class="txthighlightsmall"><strong><%# DataBinder.Eval(Container, "DataItem.ReviseTotalQty") %></strong></span><span class="txthighlightsmall">
																				</span>
																			</td>
																			<td width="9%" align="center"><span class="txthighlightsmall"><strong><%# DataBinder.Eval(Container, "DataItem.QtyCompletedLast") %></strong></span><span class="txthighlightsmall">
																				</span><input type="hidden" runat="server" id="hidQtyCompletedLast" value='<%# DataBinder.Eval(Container, "DataItem.QtyCompletedLast") %>'>
																			</td>
																			<td width="9%" align="center"><span class="txthighlightsmall"><asp:textbox  Text='<%# DataBinder.Eval(Container, "DataItem.QtyCompletedNew") %>' onkeypress="NumberOnly(0)" id="txtQuantityCompleted" runat="server" CssClass="numerictxtsmall"
																			size="3" MaxLength="5"></asp:textbox><SPAN class="txthighlight"><STRONG>* </STRONG></SPAN>
																					<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" CssClass="txthighlight" Display="Dynamic"
																						ErrorMessage="Missing quantity completed" ControlToValidate="txtQuantityCompleted" Enabled="False">required</asp:requiredfieldvalidator><asp:comparevalidator id="comvQuantityCompleted" runat="server" CssClass="txthighlight" Display="Dynamic"
																						ErrorMessage="Quantity Completed must >= 0" ControlToValidate="txtQuantityCompleted" Operator="GreaterThanEqual" ValueToCompare="0" Type="Integer" Enabled="False">msut > 0</asp:comparevalidator></td>
																			<td width="9%" align="center"><span class="txthighlightsmall"> <strong>
																						<%# DataBinder.Eval(Container, "DataItem.QtyB50Last") %>
																					</strong></span><span class="txthighlightsmall"></span><input type="hidden" runat="server" id="hidQtyB50Last" value='<%# DataBinder.Eval(Container, "DataItem.QtyB50Last") %>'>
																			</td>
																			<td width="9%" align="center"><asp:textbox Text='<%# DataBinder.Eval(Container, "DataItem.QtyB50New") %>' onkeypress="NumberOnly(0)" id="txtQuantityBelow50" runat="server" CssClass="numerictxtsmall"
																		size="3" MaxLength="5"></asp:textbox><SPAN class="txthighlight"><STRONG>* </STRONG></SPAN>
																				<asp:requiredfieldvalidator id="Requiredfieldvalidator5" runat="server" CssClass="txthighlight" Display="Dynamic"
																					ErrorMessage="Missing quantity in progress below 50%" ControlToValidate="txtQuantityBelow50" Enabled="False">required</asp:requiredfieldvalidator><asp:comparevalidator id="comvBelow50" runat="server" CssClass="txthighlight" Display="Dynamic" ErrorMessage="Quantity in progress  below 50% must >= 0"
																					ControlToValidate="txtQuantityBelow50" Operator="GreaterThanEqual" ValueToCompare="0" Type="Integer" Enabled="False">must > 0</asp:comparevalidator></td>
																			<td width="9%" align="center"><span class="txthighlightsmall"> <strong>
																						<%# DataBinder.Eval(Container, "DataItem.QtyA50Last") %>
																					</strong></span><span class="txthighlightsmall"></span><input type="hidden" runat="server" id="hidQtyA50Last" value='<%# DataBinder.Eval(Container, "DataItem.QtyA50Last") %>' NAME="Hidden1">
																			</td>
																			<td width="9%" align="center"><span class="txthighlightsmall">
																					<asp:textbox Text='<%# DataBinder.Eval(Container, "DataItem.QtyA50New") %>' onkeypress="NumberOnly(0)" id="txtQuantityAbove50" runat="server" CssClass="numerictxtsmall"
																			size="3" MaxLength="5">
																					</asp:textbox><SPAN class="txthighlight"><STRONG>*</STRONG></SPAN>
																					<asp:requiredfieldvalidator id="RequiredFieldValidator3" runat="server" CssClass="txthighlight" Display="Dynamic"
																						ErrorMessage="Missing quantity in progress above 50%" ControlToValidate="txtQuantityAbove50" Enabled="False">required</asp:requiredfieldvalidator><asp:comparevalidator id="comvAbove50" runat="server" CssClass="txthighlight" Display="Dynamic" ErrorMessage="Quantity in progress above 50%  must >= 0"
																						ControlToValidate="txtQuantityAbove50" Operator="GreaterThanEqual" ValueToCompare="0" Type="Integer" Enabled="False">must > 0</asp:comparevalidator></td>
																			<td align="center"><span class="txthighlightsmall"> <strong>
																						<%# DataBinder.Eval(Container, "DataItem.EstCompletedLast") %>
																					</strong></span><input type="hidden" runat="server" id="hidEstCompletedLast" value='<%# DataBinder.Eval(Container, "DataItem.EstCompletedLast") %>' NAME="Hidden1">
																			</td>
																			<td><table border="0" cellpadding="0" cellspacing="0">
																					<tr>
																						<td><asp:textbox Text='<%# DataBinder.Eval(Container, "DataItem.EstCompletedNew") %>' id="txt100CompletedDate" runat="server" CssClass="txtsmall" size="13" ReadOnly="True"></asp:textbox></td>
																						<td><A onclick="<%# GetDatePickupLink(Container) %>" href="javascript:doNothing()" ><IMG height="20" hspace="1" src="../images/b_date.gif" width="22" border="0"></A></td>
																						<td><span class="txthighlight"><strong>*
																									<asp:requiredfieldvalidator id="reqv100Completed" runat="server" CssClass="highlight" Display="Dynamic" ErrorMessage="Missing Estimated 100% completion date"
																										ControlToValidate="txt100CompletedDate" Enabled="False">required</asp:requiredfieldvalidator></strong></span></td>
																					</tr>
																				</table>
																			</td>
																			<td align="center"><a href="javascript:doNothing();" onclick='LoadPreviousWeekValues(<%# DataBinder.Eval(Container, "DataItem.BOIndex") %>, <%# DataBinder.Eval(Container, "DataItem.HavePreviousValue") %>)' ><img src="../images/ic_history.gif" width="15" height="16" border="0"></a></td>
																		</tr>
																		<%# GetPOTransferedLink(Container) %>
																	</ItemTemplate>
																	<FooterTemplate>
												</TABLE>
												</FooterTemplate> </asp:repeater></td>
										</tr>
									</table>
									<TABLE id="Table7" cellSpacing="0" cellPadding="3" width="100%" border="0">
										<TR class="txtnormal">
											<TD class="bgsubmenu" vAlign="bottom" align="right" height="30">All fields with red 
												mark (<span class="txthighlight">*</span>) are required fields.</TD>
										</TR>
										<TR class="txtnormal">
											<TD class="txtsmall" align="center" height="40">&nbsp;<asp:button id="btnSave" runat="server" CssClass="button" Text="Save"></asp:button>&nbsp;<asp:button id="btnSaveAndCont" runat="server" CssClass="button" Text="Save &amp; Continue"></asp:button>&nbsp;<asp:button id="txtReset" runat="server" CssClass="button" Text="Reset" CausesValidation="False"></asp:button>&nbsp;<asp:button id="btnCancel" runat="server" CssClass="button" Text="Cancel" CausesValidation="False"></asp:button>
												<script event="onclick" for="btnCancel">return (confirm('Are you sure you want to cancel?'));</script>
											</TD>
										</TR>
									</TABLE>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td align="right">&nbsp;</td>
				</tr>
			</table>
			</TD></TR><asp:validationsummary id="ValidationSummary1" runat="server" HeaderText="Following error(s) were found:"
				ShowMessageBox="True" ShowSummary="False"></asp:validationsummary><uc1:footer id="Footer1" runat="server"></uc1:footer></TBODY></TABLE></form>
	</body>
</HTML>
